package com.ttn.student.controller;

import com.ttn.common.core.entity.Result;
import com.ttn.common.core.entity.studentrecord.OralPracticeStudyRecordDetails;
import com.ttn.common.core.entity.studentrecord.query.QueryStudyLeaderboardQuery;
import com.ttn.common.core.entity.studentrecord.query.TestStudyRecordQuery;
import com.ttn.student.service.OralPracticeStudyRecordDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * (oral_practice_study_record_details)表控制层
 *
 * @author xxxxx
 */
@RestController
@Slf4j
@RequestMapping("/oral-practice-study-record-details")
public class OralPracticeStudyRecordDetailsController {
    /**
     * 服务对象
     */
    @Resource
    private OralPracticeStudyRecordDetailsService oralPracticeStudyRecordDetailsService;

    /**
     * 保存口语跟读测试
     *
     * @param request
     * @param oralPracticeStudyRecordDetails
     * @return
     */

    @PostMapping("/save/oral-practice-study-record-details")
    public Result saveOralPracticeStudyRecordDetails(HttpServletRequest request, @RequestBody OralPracticeStudyRecordDetails oralPracticeStudyRecordDetails) {
        log.info("OralPracticeStudyRecordDetailsController saveOralPracticeStudyRecordDetails ,参数:{}", oralPracticeStudyRecordDetails);

        return oralPracticeStudyRecordDetailsService.saveOralPracticeStudyRecordDetails(oralPracticeStudyRecordDetails);
    }

    /**
     * 查询口语跟读排行榜
     *
     * @param request
     * @param oralPracticeStudyRecordDetails
     * @return
     */

    @PostMapping("/query/oral-practice-study-leader-board")
    public Result queryOralPracticeStudyLeaderboard(HttpServletRequest request,
                                                    @RequestBody QueryStudyLeaderboardQuery queryStudyLeaderboardQuery) {
        log.info("OralPracticeStudyRecordDetailsController queryOralPracticeStudyLeaderboard ,参数:{}", queryStudyLeaderboardQuery);
        return oralPracticeStudyRecordDetailsService.queryOralPracticeStudyLeaderboard(queryStudyLeaderboardQuery);
    }

    /**
     * 查询测试记录
     * @param request
     * @param testStudyRecordQuery
     * @return
     */
    @PostMapping("/query/oral-practice-study-record-details")
    public Result queryOralPracticeStudyRecordDetails(HttpServletRequest request, @RequestBody TestStudyRecordQuery testStudyRecordQuery) {

        log.info("VocabularyStudyRecordDetailsController queryOralPracticeStudyRecordDetails ,参数:{}", testStudyRecordQuery);
        return oralPracticeStudyRecordDetailsService.queryOralPracticeStudyRecordDetails(testStudyRecordQuery);
    }

}
